Median filter with different window lengths (2015.10.08 DW KT)


In [1]:
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.backends.backend_pdf import PdfPages
import sys
sys.path.insert(0, 'C:\Users\Dominik\Documents\GitRep\kt-2015-DSPHandsOn\MedianFilter\Python') #Add a new path with needed .py files

import functions
import gitInformation

In [2]:
gitInformation.printInformation()


Information about this notebook
============================================================
Date: 2015-11-10
Python Version: 2.7.10 |Anaconda 2.3.0 (64-bit)| (default, May 28 2015, 16:44:52) [MSC v.1500 64 bit (AMD64)]
Git directory: C:\Users\Dominik\Documents\GitRep\kt-2015-DSPHandsOn\.git
Current git SHA: 3d75389fd98bd111b1e723db4da574f17ba90e9b
Remotes: fork, origin, 
Current branch: master
fork remote URL: http://github.com/dowa4213/kt-2015-DSPHandsOn.git
origin remote URL: https://github.com/ktakagaki/kt-2015-DSPHandsOn.git

In [3]:
% matplotlib inline

Here I'm plotting sine waves with different wave numbers. The different sine waves get median filtered and the filtered wave is displayed in the same plot. At least I am calculating the difference between the sine wave and the median filtered wave.

Plot

Here you can see the result. The blue wave is the sine, green the filtered wave and red is the difference between sine wave and filtered wave.


In [4]:
pp = PdfPages('median sin with different window lengths.pdf')
for z in range (3, 16, 2):
    # Creates different figures in one plot, z is the window length.
    fig = plt.figure(z, figsize=(30,20)) 
    for x in range(1, 5):
        for y in range(1, 6):
            # Creates different subplots in one figure, with x and y
            # the wave number is calculated.
            plt.subplot(5, 5, x + (y-1)*4)  
            wavenum = (x-1) + (y-1)*4
            functions.medianSinPlot( wavenum, z )
            plt.suptitle('Median filtered sine waves with window length ' + 
                         str(z), fontsize = 60)
            plt.xlabel(("Wave number = "+str((x-1) + (y-1)*4)), fontsize=18)
    pp.savefig(fig)
pp.close()